<template>
    <div>
      <el-popover
        placement="bottom"
        :width="1700"
        v-model:visible="showProduct"
        trigger="hover"
      >
        <template #reference>
          <el-button text style="align-items: center; font-size: 20px;" @click="togglePopover">
            全部商品
          </el-button>
        </template>
        <div class="first_div" >
          <div class="link-group-list">
            <div  class="link-group" style="margin-left: auto; margin-right: auto;" v-for="(item,index) in menu" :key="index">
              <el-image :src="Path.imgPath + item.icon" style=" width: 50px; height: 50px;"></el-image>
              <el-link class="link-text no-underline" style="font-weight: 800;text-decoration: none;cursor: default;color: #000;" >{{ item.name }}</el-link>
              <el-link v-for="(itemSon,index) in item.children" :key="index" @click="turn(itemSon.id)"
              class="link-text" >{{ itemSon.name }}</el-link>
            </div>
            <hr />
          </div>

          <div class="image-group">
            <div>
              <el-image :src="url" width="150px" height="150px"></el-image>
            </div>
            <div style="width: 270px;">
              <el-text type="info" style="font-family:Arial, Helvetica, sans-serif; font-style: italic;">商城功能丰富多样，旨在为消费者提供便捷、安全、高效的在线购物体验。
              </el-text>
            </div>
          </div>
        </div>
      </el-popover>
    </div>
  </template>
  
  <script setup>
  import { ref } from 'vue';
  import { get,post } from "@/plugins/axios"
  import { Path } from "@/constant/index"
  import router from '@/router';
  const url ='/images/menu_picture/商城.png'
  const showProduct = ref(false)
  const menu = ref([])
  getMenu()
  function getMenu(){
    get(Path.categoryList,{},content => {
      menu.value = content
    })
  }
    //跳转函数别改
    const turn =(categoryId)=>{
      console.dir(categoryId)
      router.push({
        name:'Store',
        query:{
            categoryId
        }
      })
  }
  const togglePopover = () => {
    showProduct.value = !showProduct.value
  }
  </script>
  
  <style scoped lang="scss">
  .no-underline:hover{
    text-decoration: none;
  }
  .first_div {
    display: flex;
    min-height: 40vh;
    padding: 0 200px;
    .link-group-list {
      flex: 1;
      display: flex;
      justify-content: center;
      flex-wrap: wrap;
    }
  }
  .el-button + .el-button {
    margin-left: 8px;
  }
  .link-text {
    margin-top: 10px;
    font-size: large;
    font-weight: 500;

    
  }
  .link-group {
    display: flex;
    flex-direction: column;
    margin-left: 150px;
    margin-top: 50px;
    min-width: 200px;
    font-size: large;
    align-items: center;
  }
  .image-group {
    display: flex;
    flex-direction: column;
    width: 270px;
    height: 250px;
    margin-left: 100px;
  }
  .divider {
    hr {
      margin-left: 150px;
      margin-top: 50px;
      margin-bottom: 50px;
      width: 1px;
      height: 300px;
      background-color: #000000;
    }
  }
  </style>